const path = require('path');
const express = require('express');
const webpack = require('webpack');
const webpackConfig = require('./webpack.config');
const compiler = webpack(webpackConfig);

const app = express();

app.use(express.static(path.join(__dirname,"src")));

app.use(require("webpack-dev-middleware")(compiler, {
    publicPath: webpackConfig.output.publicPath,
    stats: {
        colors: true
    }
}));

app.use(require("webpack-hot-middleware")(compiler));

app.listen(9999, 'localhost', function(err) {
    if (err) {
        console.log(err);
        return;
    }
    console.log('Server listening on http://localhost:9999')
});
